angular.module('service.relation', ['ngResource', 'ngCookies'])

//relation
    .service('RelationService', ['$resource', function ($resource) {
        //添加联系
        this.add= function (relation, success, error) {
            var resource = $resource(marketurl + "relation");
            return resource.save({}, relation, success, error);
        }
        //通过mid,get
        this.getbymid = function (mid) {
            var resource = $resource(marketurl + "relation/mid/:mid");
            return resource.query({mid: mid});
        }



        /*//通过aid,get
        this.getbyaid = function (aid) {
            var resource = $resource(testurl + "relation/aid/:aid");
            return resource.query({aid: aid});
        }


        //删除advcontent
        this.deletebyid = function (mid, aid) {
            var resource = $resource(testurl + "relation/:mid/:aid");
            return resource.remove({mid: mid, aid: aid});
        }
        //更新
        this.updatebyid = function (mid,aid, relation) {
            var resource = $resource(testurl + "relation/:mid/:aid", {}, {update: {method: "PUT"}});
            return resource.update({mid: mid, aid: aid}, relation);
        }



        // this.getoutdate=function(){
        //     var resource = $resource(testurl + "relation/outdated");
        //     return resource.query();
        // }
        this.getoutdate=function(start,end){
            var resource = $resource(testurl + "relation/available?starttime=:starttime&endtime=:endtime");
            return resource.query({starttime:start,endtime:end});
        }

        //
        this.linkAllRelation=function(id){
            var resource = $resource(testurl + "relation/aidall/:id");
            return resource.query({id:id});
        }
        this.linkAllInvalidrel=function(id){
            var resource = $resource(testurl + "invalidrel/aidall/:id");
            return resource.query({id:id});
        }
        this.linkByaidList=function(aidList){
            var resource = $resource(testurl + "relation/aidlist?aidlist=:aidList");
            return resource.query({aidList:aidList});
        }
*/

    }])

